package com.example.xiang.myapplication;

import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

public class MainActivity extends AppCompatActivity implements
        NavFragment.OnNavigationReselectListener{
    private NavFragment mNavBar;

    private OnNavigationReselectListener mOnNavigationReselectListener;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initWidget();
    }

   // @Override
    protected void initWidget() {
       // super.initWidget();
        FragmentManager manager = getSupportFragmentManager();
        mNavBar = ((NavFragment) manager.findFragmentById(R.id.fag_nav));
        mNavBar.setup(this, manager, R.id.main_container, this);

//        if (AppContext.get("isFirstComing", true)) {
//            View view = findViewById(R.id.layout_ripple);
//            view.setVisibility(View.VISIBLE);
//            view.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    ((ViewGroup) v.getParent()).removeView(v);
//                    AppContext.set("isFirstComing", false);
//                }
//            });
//        }
    }
    public void onReselect(NavigationButton navigationButton) {
        OnNavigationReselectListener listener = mOnNavigationReselectListener;
        if (listener != null) {
            listener.onReselect(navigationButton);
        }
    }
    public interface OnNavigationReselectListener {
        void onReselect(NavigationButton navigationButton);
    }
}
